<?php
/***************************************************************************
 *
 *   copyright            : (C) 2005 Winds of Storm
 *
 *   $Id: proxy.php,v 1.2 2007/01/30 21:02:43 nathan Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

//
// Turn off PHP's max_execution_time limit...
//
set_time_limit(0);

require("config.php");
$skip_header	= 1;
require($libdir . "init." . $phpEx);

$url	= "http://" . $config['CHAT_SERVER'] . ":" . $config['CHAT_PORT'] . "/?sid=" . $_REQUEST['sid'];
$chunk	= 256;

$fh	= fopen($url, "r");

if ($fh) {
	stream_set_blocking($fh, 0);
	stream_set_timeout($fh, 2);
	while (!feof($fh)) {
		$buffer = '';
		$buffer = fread($fh, $chunk);
		echo $buffer;
		flush();
		ob_flush();
	}
	fclose($fh);
}
